import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/ipad/login'
        },
        {
            path: '/login',
            name: 'login',
            component: resolve => require(['@/views/login/login.vue'], resolve), //登录
        },
        {
            path: '/securityMap',
            name: 'securityMap',
            component: resolve => require(['@/views/securityMap/securityMap.vue'], resolve), //天生保卫图
        },
        {
            path: '/layout',
            component: resolve => require(['@/views/layout/layout.vue'], resolve), // 外壳
            children: [
                {
                    path: '/layout/guardThroughTrain',
                    name: 'guardThroughTrain',
                    component: resolve => require(['@/views/layout/guardThroughTrain/guardThroughTrain.vue'], resolve), //保卫直通车
                },
                {
                    path: '/layout/guardThroughTrain/activeDetail',
                    name: 'guardThroughTrain/activeDetail',
                    component: resolve => require(['@/views/layout/guardThroughTrain/activeDetail/activeDetail.vue'], resolve), // 活动详情
                },
                {
                    path: '/layout/guardThroughTrain/createActive',
                    name: 'guardThroughTrain/createActive',
                    component: resolve => require(['@/views/layout/guardThroughTrain/createActive/createActive.vue'], resolve), // 新增活动
                },
                {
                    path: '/layout/guardThroughTrain/dataDictionary',
                    name: 'guardThroughTrain/dataDictionary',
                    component:  resolve => require(['@/views/layout/guardThroughTrain/dataDictionary/dataDictionary.vue'], resolve), // 数据字典
                },
                {
                    path: '/layout/activityStatistics',
                    name: 'activityStatistics',
                    component:  resolve => require(['@/views/layout/activityStatistics/activityStatistics.vue'], resolve), // 统计活动
                },
                {
                    path: '/layout/guardianHouse',
                    name: 'guardianHouse',
                    component: resolve => require(['@/views/layout/guardianHouse/guardianHouse.vue'], resolve), // 卫士之家
                },
                {
                    path: '/layout/guardianHouse/createVolunteer',
                    name: 'guardianHouse/createVolunteer',
                    component: resolve => require(['@/views/layout/guardianHouse/createVolunteer/createVolunteer.vue'], resolve), // 新增志愿者
                },
            ]
        },
        /*ipad开始*/

        {
            path: '/ipad/login',
            name: 'ipad/login',
            component: resolve => require(['@/views/ipad/login/login.vue'], resolve), //登录
        },
        {
            path: '/ipad/securityMap',
            name: 'ipad/securityMap',
            component: resolve => require(['@/views/ipad/securityMap/securityMap.vue'], resolve), //天生保卫图
        },
        {
            path: '/ipad/layout',
            component: resolve => require(['@/views/ipad/layout/layout.vue'], resolve), // 外壳
            children: [
                {
                    path: '/ipad/layout/guardThroughTrain',
                    name: 'ipad/guardThroughTrain',
                    component: resolve => require(['@/views/ipad/layout/guardThroughTrain/guardThroughTrain.vue'], resolve), //保卫直通车
                },
                {
                    path: '/ipad/layout/guardThroughTrain/activeDetail',
                    name: 'ipad/guardThroughTrain/activeDetail',
                    component: resolve => require(['@/views/ipad/layout/guardThroughTrain/activeDetail/activeDetail.vue'], resolve), // 活动详情
                },
                {
                    path: '/ipad/layout/guardThroughTrain/createActive',
                    name: 'ipad/guardThroughTrain/createActive',
                    component: resolve => require(['@/views/ipad/layout/guardThroughTrain/createActive/createActive.vue'], resolve), // 新增活动
                },
                {
                    path: '/ipad/layout/guardThroughTrain/dataDictionary',
                    name: 'ipad/guardThroughTrain/dataDictionary',
                    component:  resolve => require(['@/views/ipad/layout/guardThroughTrain/dataDictionary/dataDictionary.vue'], resolve), // 数据字典
                },
                {
                    path: '/ipad/layout/activityStatistics',
                    name: 'ipad/activityStatistics',
                    component:  resolve => require(['@/views/ipad/layout/activityStatistics/activityStatistics.vue'], resolve), // 统计活动
                },
                {
                    path: '/ipad/layout/guardianHouse',
                    name: 'ipad/guardianHouse',
                    component: resolve => require(['@/views/ipad/layout/guardianHouse/guardianHouse.vue'], resolve), // 卫士之家
                },
                {
                    path: '/ipad/layout/guardianHouse/createVolunteer',
                    name: 'ipad/guardianHouse/createVolunteer',
                    component: resolve => require(['@/views/ipad/layout/guardianHouse/createVolunteer/createVolunteer.vue'], resolve), // 新增志愿者
                },
            ]
        },

        /*ipad结束*/
        /*移动端*/
        {
            path: '/mobileLogin',
            name: 'mobileLogin',
            component: resolve => require(['@/views/mobileLogin/mobileLogin.vue'], resolve), //登录
        },
        {
            path: '/mobileRegister',
            name: 'mobileRegister',
            component: resolve => require(['@/views/mobileRegister/mobileRegister.vue'], resolve), //注册
        },
        {
            path: '/mobileLayout',
            component: resolve => require(['@/views/mobileLayout/mobileLayout.vue'], resolve), // 外壳
            children: [
                {
                    path: '/mobileLayout/mobileHome',
                    name: 'mobileHome',
                    component: resolve => require(['@/views/mobileLayout/mobileHome/mobileHome.vue'], resolve), // 首页
                },
                {
                    path: '/mobileLayout/mobileHome/rank',
                    name: 'mobileHome/rank',
                    component: resolve => require(['@/views/mobileLayout/mobileHome/rank/rank.vue'], resolve), // 卫士排名/卫士单位排名
                },

                {
                    path: '/mobileLayout/mobileActiveSign',
                    name: 'mobileActiveSign',
                    component: resolve => require(['@/views/mobileLayout/mobileActiveSign/mobileActiveSign.vue'], resolve), // 活动报名
                },
                {
                    path: '/mobileLayout/mobileActiveSign/mobileActiveDetail',
                    name: 'mobileActiveSign/mobileActiveDetail',
                    component: resolve => require(['@/views/mobileLayout/mobileActiveSign/mobileActiveDetail/mobileActiveDetail.vue'], resolve), // 活动详情
                },
                {
                    path: '/mobileLayout/mobilePersonal',
                    name: 'mobilePersonal',
                    component: resolve => require(['@/views/mobileLayout/mobilePersonal/mobilePersonal.vue'], resolve), // 个人中心
                },
                {
                    path: '/mobileLayout/mobilePersonal/modifyPersonal',
                    name: 'mobilePersonal/modifyPersonal',
                    component: resolve => require(['@/views/mobileLayout/mobilePersonal/modifyPersonal/modifyPersonal.vue'], resolve), // 修改个人信息
                },

            ]
        },
    ]
})

export default router;